package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.LagouSecurity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@LagouController
@LagouRequestMapping("/demo")
@LagouSecurity("classUser")
public class DemoController {

    @LagouAutowired
    private IDemoService demoService;
    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param username
     * @return
     */
    @LagouSecurity("queryUser")
    @LagouRequestMapping("/query")
    public void query(HttpServletRequest request, HttpServletResponse response,String username) {
        try {
            response.getWriter().write("query by user["+username+"]");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @LagouSecurity({"indexUser","indexUser"})
    @LagouRequestMapping("/index")
    public void index(HttpServletRequest request, HttpServletResponse response,String username) {
        try {
            response.getWriter().write("into index page by user["+username+"]");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
